package com.longai.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import util.Page;

import com.longai.model.*;
@Repository
public class PictureDAO extends BaseDAO{
	public void save(Picture picture){
		super.saveOrUpdate(picture);
	}
	public void delete(Picture picture){
		super.delete(picture);
	}
	public Picture findById(int id){
		return (Picture)super.findById(id, Picture.class);
	}
	public List<Picture> findAll(){
		Map<String, Object>map=null;
		String queryStr="from Picture";
		return super.queryAll(queryStr, map);
	}
    public List<Picture> findByUserId(String str) {
    	Map<String, Object> map = null;
		String queryStr = "from Picture where user_id='"+str+"'";
		return super.queryAll(queryStr, map);
	}
    
//    public Picture queryByUserId(int user_id)
//    {
//    	Map<String, Object> map = new HashMap<String, Object>();
//    	String ttt = Integer.toString(user_id);
//    	String queryStr = "from Picture as a  where a.user_id='" + ttt+"'";
//    	//String queryStr = "from Picture as A where A.user_id=" + user_id;
//    	map.put("user_id", ttt);
//    	return (Picture) super.queryIdentity(queryStr,map);
//    }
    
    public Page findByUserId(String str,String currentPage,String amount) {
    	Map<String, Object> map = null;
		String queryStr = "from Picture where user_id='"+str+"'";
		return super.queryByPage(queryStr, map, currentPage, amount);
	}
    
}
